{# ----------------------------------------------------------------------------
 # SymForce - Copyright 2022, Skydio, Inc.
 # This source code is under the Apache 2.0 license found in the LICENSE file.
 # ---------------------------------------------------------------------------- #}

{%- import "../../util/util.jinja" as util with context -%}

#include <cmath>

#include <sym/{{ camelcase_to_snakecase(cls.__name__) }}.h>

#include "./lie_group_ops.h"

namespace sym {

{% set type_prefix = "LieGroupOps<" + cls.__name__ + "<Scalar>>" %}
{% for spec in specs['LieGroupOps'] %}
template <typename Scalar>
{% set raw_declaration = util.function_declaration_custom_namespace(spec, type_prefix, is_declaration=False) %}
{% set declaration = raw_declaration.replace(
    "Eigen::Matrix<Scalar, {}, 1>".format(ops.LieGroupOps.tangent_dim(cls)), "TangentVec"
)%}
{% if declaration.startswith("TangentVec") %}
typename {{ type_prefix }}::{{ declaration }}
{% else %}
{{ declaration }}
{% endif %} {
    {{ util.expr_code(spec) -}}
}

{% endfor %}

}  // namespace sym

// Explicit instantiation
{% for Scalar in scalar_types %}
template struct sym::LieGroupOps<sym::{{ cls.__name__ }}<{{ Scalar }}>>;
{% endfor %}
